﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace PRE.Catalog
{
    public partial class FrmXemdiem : DevExpress.XtraEditors.XtraForm
    {
        DAL.EntitesDAL.BangdiemDAL _dal = new DAL.EntitesDAL.BangdiemDAL();
        DAL.EntitesDAL.KhoahocDAL _dal1 = new DAL.EntitesDAL.KhoahocDAL();
        DAL.EntitesDAL.LophocDAL _dal2 = new DAL.EntitesDAL.LophocDAL();
        DAL.EntitesDAL.HocvienDAL _dal3 = new DAL.EntitesDAL.HocvienDAL();

        BLL.EntitiesBLL.BangdiemBLL _bll = new BLL.EntitiesBLL.BangdiemBLL();

        public FrmXemdiem()
        {
            InitializeComponent();
        }

        private void FrmNhapdiem_Load(object sender, EventArgs e)
        {
           DataTable _dtb1 = _dal1.Select_Current(DateTime.Now);
           string _id1 = _dtb1.Rows[0]["Makhoa"] + "";
           cboLophoc.Properties.DataSource = _dal2.Select(_id1);

            ReadOnlyControl();            
        }

        private void ReadOnlyControl(bool isTrue = true)
        {
            cboHocvien.Properties.ReadOnly = isTrue;
        }

        private void cboLophoc_EditValueChanged(object sender, EventArgs e)
        {
            ReadOnlyControl(false);
            string _id = cboLophoc.EditValue + "";

            DataTable _dtb2 = _dal3.Select_Nhapdiem(_id);
            cboHocvien.Properties.DataSource = _dtb2;
            cboHocvien.ItemIndex = 0;

            DataTable _dtb = _dal.Select(_id);
            if (_dtb != null)
                grcMain.DataSource = _dtb;
        }
    

        private void btnDong_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        
    }
}